from game import zz_game
from zz import zz_log, zz_img

log = zz_log.of()


class Game(zz_game.ZZ_Game):
    def __init__(self, d):
        super().__init__(d)

    def get_name(self):
        return "乌冬的旅店"

    def game_alert(self):
        self.log_msg("检查是否存在弹窗")
        while True:
            if self.alert_close('./game/img/乌冬的旅店/alert.png'):
                continue
            if self.alert_close('./game/img/乌冬的旅店/alert01.png', 2):
                continue
            if self.alert_close('./game/img/乌冬的旅店/alert02.png', 2):
                continue
            break

    def handle_main(self):
        self.log_msg("等待进入游戏主界面")
        self.img_exit('./game/img/乌冬的旅店/game_main.png', 100)
        self.log_msg("已进入游戏主界面")

        self.game_alert()

        self.log_msg("开始点击路人")
        while not self.check_done():
            for i in range(5):
                self.log_msg(f"{i + 1}-点击路人")
                self.img_click('./game/img/乌冬的旅店/play.png', 5, 20)
                self.img_click('./game/img/乌冬的旅店/play01.png', 5, 20)

        return True
